﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gfw.Models.Admin;
using Gfw.Repository;

namespace Gfw.Repositories.Admin
{
    public class UsrUserFinanceRepository : Repository<UsrUserfinance>
    {
        #region 基础操作部分

        /// <summary>
        /// 根据用户id获取用户财务信息
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="unitOfWork"></param>
        /// <returns></returns>
        public UsrUserfinance GetUserFinanceByUserID(string userID, UnitOfWork unitOfWork = null)
        {
            if (unitOfWork == null)
            {
                var query = Session.CreateQuery(
                    @"from UsrUserfinance as u where u.Userid=:userID")
                    .SetString("userID", userID);
                return query.List<UsrUserfinance>().FirstOrDefault();
            }
            else
            {
                var query = unitOfWork.Session.CreateQuery(
                    @"from UsrUserfinance as u where u.Userid=:userID")
                    .SetString("userID", userID);
                return query.List<UsrUserfinance>().FirstOrDefault();
            }
        }

        #endregion
    }
}
